#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.db import models

class Tag(models.Model):
    name = models.CharField(max_length=200)
    #post_count = models.IntegerField(default=0)

    def __unicode__(self):
        return self.name

class Post(models.Model):
    TYPE_CHOICES = (
            (u'post', u'a general post'),
            (u'page', u'a page'),
            (u'draft', u'a post or page but not finished'),
    )
#    author = models.ForeignKey(Author)
    date = models.DateTimeField(auto_now_add=True)
    content = models.TextField()
    title = models.CharField(max_length=100)
    slug = models.CharField(max_length=200, blank=True)
    modified = models.DateTimeField(auto_now=True)
    type = models.CharField(max_length=20,choices=TYPE_CHOICES)
    comment_count = models.IntegerField(default=0)
    tags = models.ManyToManyField(Tag, blank=True, null=True)

    def __unicode__(self):
        return self.title

class Comment(models.Model):
    post = models.ForeignKey(Post)
    author = models.CharField(max_length=30)
    author_email = models.CharField(max_length=100)
    author_url = models.CharField(max_length=200)
    author_ip = models.CharField(max_length=100)
    date = models.DateTimeField(auto_now=True)
    content = models.TextField()

    def __unicode__(self):
        return self.content

class Link(models.Model):
    url = models.CharField(max_length=100)
    name = models.CharField(max_length=50)
    date = models.DateTimeField(auto_now=True)
    description = models.CharField(max_length=200, blank=True, null=True)

    def __unicode__(self):
        return self.name
